package com.hang.springrabbitmq.hello.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hello")
public class TestRabbitMq {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/sayHello")
    @ResponseBody
    public String testHello(){
        //转换和发送    1.routingKey 2.消息
        rabbitTemplate.convertAndSend("hello","hello world");
        return "ok";
    }
}
